package com.qyhl.module_home.new_message;

import com.qyhl.module_home.common.HomeUrl;
import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.entity.user.MessageUnreadBean;

public class MessageModel implements MessageContract.MessageModel {
    private MessagePresenter mPresenter;

    MessageModel(MessagePresenter messagePresenter) {
        this.mPresenter = messagePresenter;
    }

    @Override
    public void getUnreadMsgNum(String sTime,String tTime, String userName) {

        EasyHttp.get(HomeUrl.GET_UNREAD_MSG_NUM)
                .params("siteId", CommonUtils.getInstance().getSite() + "")
                .params("devType", "Android")
                .params("sTime", sTime)
                .params("tTime",tTime)
                .params("userName", userName)
                .execute(new SimpleCallBack<MessageUnreadBean>() {
                    @Override
                    public void onError(ApiException e) {

                    }

                    @Override
                    public void onSuccess(MessageUnreadBean messageUnreadBean) {
                        mPresenter.setUnreadBadge(messageUnreadBean);
                    }
                });

    }
}
